home *** CD-ROM | disk | FTP | other *** search
/ Amiga Games Extra 1996 September / Amiga Games Extra CD-ROM 9-1996.iso / userbox / publicdomain / vim-4.2 / doc / vim_gui.txt < prev    next >
Text File  |  1996-06-16  |  21KB  |  510 lines

  1. *vim_gui.txt*   For Vim version 4.2.  Last modification: 1996 June 11
  2.  
  3.  
  4.                Vim's Graphical User Interface
  5.  
  6.  
  7.     1. Introduction                *gui_intro* *gui* *gvim*
  8.  
  9. 1.1 How to Start the GUI Version of Vim            *gui_start* *GUI*
  10.  
  11. First you must make sure you actually compile Vim with the GUI code
  12. included.  You can check this with the ":version" command, it should include
  13. "+GUI_Motif" or "+GUI_Athena".  Then you may run the GUI version of Vim in
  14. either of these ways:
  15.     gvim [options] [files...]
  16.     vim -g [options] [files...]
  17.  
  18. So if you call the executable "gvim", or make "gvim" a link to the
  19. executable, then the GUI version will automatically be used.  You may also
  20. start up the GUI from within the terminal version by using one of these
  21. commands:
  22.     :gui [+cmd] [-f] [files...]            *:gu* *:gui*
  23.     :gvim [+cmd] [-f] [files...]            *:gv* *:gvim*
  24.  
  25.                             *gui_fork*
  26. When the GUI is started, it does a fork() and exits the current process.
  27. When gvim was started from a shell this makes the shell accept further
  28. commands.  If you don't want this (e.g. when using gvim for a mail program
  29. that waits for gvim to exit), start gvim with "gvim -f", "vim -gf" or use
  30. ":gui -f".  Don't use "vim -fg", because "-fg" specifies the foreground
  31. color.  If you want the GUI to run in the foreground always, include the 'f'
  32. flag in 'guioptions'.  |-f|.
  33.  
  34. When the GUI starts up, the file ~/.gvimrc is sourced if it exists, and then
  35. the file ./.gvimrc.  This file may contain commands to set up your own
  36. customised menus (see |:menu|) and initialise other things that you may want
  37. to set up differently from the terminal version.
  38.  
  39. There are a number of options which only have meaning in the GUI version of
  40. Vim.  These are 'guifont', 'guipty' and 'guioptions'.  They are documented
  41. in |vim_ref.txt| with all the other options.
  42.  
  43.  
  44. 1.2 GUI Resources                    *gui_resources*
  45.  
  46. If using the Motif or Athena version of the GUI (which are the only versions
  47. available at the moment), a number of X resources are available.  You should
  48. use Vim's class "Vim" when setting these.  They are as follows:
  49.  
  50.     Resource name    Meaning
  51.  
  52.     background        Color of background.
  53.     foreground        Color of normal text.
  54.     boldColor        Color of bold text.
  55.     italicColor        Color of italic text.
  56.     underlineColor    Color of underlined text.
  57.     cursorColor        Color of the cursor.
  58.     font        Name of font used for normal text.
  59.     boldFont        Name of font used for bold text.
  60.     italicFont        Name of font used for italic text.
  61.     boldItalicFont    Name of font used for bold, italic text.
  62.     geometry        Initial geometry to use for gvim's window (default
  63.             is same size as terminal that started it).
  64.     scrollbarWidth    Thickness of scrollbars.
  65.     menuHeight        Height of the menu bar.
  66.     borderWidth        Thickness of border around text area.
  67.     reverseVideo    Boolean: should reverse video be used?
  68.     menuBackground    Color of menu backgrounds.
  69.     menuForeground    Color of menu foregrounds.
  70.     scrollBackground    Color of trough portion of scrollbars.
  71.     scrollForeground    Color of slider and arrow portions of scrollbars.
  72.  
  73. A special font for italic, bold, and italic-bold text will only be used if
  74. the user has specified one via a resource.  No attempt is made to guess what
  75. fonts should be used for these based on the normal text font at the moment.
  76.  
  77. Note: All fonts must be of the same size!!!  If you don't do this, text will
  78. disappear.  Vim does not check the font sizes.
  79.  
  80. If any of these things are also set with Vim commands, eg with
  81. ":set guifont=Screen15", then this will override the X resources (currently
  82. 'guifont' is the only option that is supported).
  83.  
  84. Here is an example of what you might put in your ~/.Xdefaults file:
  85.  
  86. Vim*useSchemes:            all
  87. Vim*sgiMode:            true
  88. Vim*useEnhancedFSB:        true
  89. Vim.foreground:            Black
  90. Vim.background:            Wheat
  91. Vim.boldColor:            Blue
  92. Vim.italColor:            Cyan
  93. Vim.underlineColor:        Brown
  94. Vim.cursorColor:        DarkGreen
  95. Vim*menuBar*font:        7x13
  96.  
  97. The first three of these are standard resources on Silicon Graphics machines
  98. which make Motif applications look even better, highly recommended!
  99.  
  100. Don't use "Vim*geometry" in the defaults.  This will break the menus.  Use
  101. "Vim.geometry" instead.
  102.  
  103. The resources can also be set with arguments to vim:
  104.  
  105.     argument        meaning                *-gui*
  106.  
  107.    -display <display>    Run vim on <display>        *-display*
  108.    -iconic        Start vim iconified        *-iconic*
  109.    -background <color>    Use <color> for the background    *-background*
  110.    -bg <color>        idem                *-bg*
  111.    -foreground <color>    Use <color> for normal text    *-foreground*
  112.    -fg <color>        idem                *-fg*
  113.    -bold <color>    Use <color> for bold text    *-bold*
  114.    -italic <color>    Use <color> for italic text    *-italic*
  115.    -underline <color>    Use <color> for underlined text    *-underline*
  116.    -ul <color>        idem                *-ul*
  117.    -cursor <color>    Use <color> for cursor        *-cursor*
  118.    -font <font>        Use <font> for normal text    *-font*
  119.    -fn <font>        idem                *-fn*
  120.    -boldfont <font>    Use <font> for bold text    *-boldfont*
  121.    -italicfont <font>    Use <font> for italic text    *-italicfont*
  122.    -geometry <geom>    Use <geom> for initial geometry    *-geometry*
  123.    -geom <geom>        idem                *-geom*
  124.    -borderwidth <width>    Use a border width of <width>    *-borderwidth*
  125.    -bw <width>        idem                *-bw*
  126.                                *-scrollbarwidth*
  127.    -scrollbarwidth <width>    Use a scrollbar width of <width>
  128.    -sw <width>        idem                *-sw*
  129.    -menuheight <height>    Use a menu bar height of <height> *-menuheight*
  130.    -mh <height>        idem                *-mh*
  131.    -reverse        Use reverse video        *-reverse*
  132.    -rv            idem                *-rv*
  133.    +reverse        Don't use reverse video        *-+reverse*
  134.    +rv            idem                *-+rv*
  135.    -xrm <resource>    Set the specified resource    *-xrm*
  136.  
  137.  
  138.     2. Scrollbars                    *gui_scrollbars*
  139.  
  140. There are vertical scrollbars and a horizontal scrollbars.  You may
  141. configure which ones appear with the 'guioptions' option.
  142.  
  143. The interface looks like this (with ":set guioptions=mlrb"):
  144.  
  145.                +------------------------------+
  146.                | File  Edit              Help | <- Menu bar (m)
  147.                +-+--------------------------+-+
  148.                |^|                          |^|
  149.                |#| Text area.               |#|
  150.                | |                          | |
  151.                |v|__________________________|v|
  152.  Normal status line -> |-+ File.c              5,2  +-|
  153.  between Vim windows   |^|""""""""""""""""""""""""""|^|
  154.                | |                          | |
  155.                | | Another file buffer.     | |
  156.                | |                          | |
  157.                |#|                          |#|
  158.  Left scrollbar (l) -> |#|                          |#| <- Right
  159.                |#|                          |#|    scrollbar (r)
  160.                | |                          | |
  161.                |v|                          |v|
  162.                +-+--------------------------+-+
  163.                | |< ####                   >| | <- Bottom
  164.                +-+--------------------------+-+    scrollbar (b)
  165.  
  166. Any of the scrollbar or menu components may be turned off by not putting the
  167. appropriate letter in the 'guioptions' string.  The bottom scrollbar is
  168. only useful when 'nowrap' is set.
  169.  
  170.  
  171. 2.1 Vertical Scrollbars                    *gui_vert_scroll*
  172.  
  173. Each Vim window has a scrollbar next to it which may be scrolled up and down
  174. to move through the text in that buffer.  The size of the scrollbar-thumb
  175. indicates the fraction of the buffer which can be seen in the window.
  176. When the scrollbar is dragged all the way down, the last line of the file
  177. will appear in the top of the window.
  178.  
  179.  
  180. 2.2 Horizontal Scrollbars                *gui_horiz_scroll*
  181.  
  182. The horizontal scrollbar (at the bottom of the Vim GUI) may be used to
  183. scroll text sideways when the 'wrap' option is turned off.  The
  184. scrollbar-thumb size is such that the text of the current cursor line may be
  185. scrolled as far as possible left and right.
  186.  
  187.  
  188.     3. Mouse Control                *gui_mouse*
  189.  
  190. The mouse only works if the appropriate flag in the 'mouse' option is set.
  191. When the GUI is switched on the 'mouse' option is set to "a", enabling
  192. it for all modes except for the "hit return to continue" message. This can
  193. be changed from the "gvimrc" file.
  194.  
  195.  
  196. 3.1 Moving Cursor with Mouse                *gui_mouse_move*
  197.  
  198. Click the left mouse button where you want the cursor to go, and it does!
  199. This works in Normal mode (if 'mouse' contains 'n' or 'a'), Visual mode (if
  200. 'mouse' contains 'v' or 'a') and Insert mode (if 'mouse' contains 'i' or
  201. 'a'), if you click the mouse somewhere in a text buffer. You may use this
  202. with an operator such as 'd' to delete text from the current cursor position
  203. to the position you point to with the mouse.  That is, you hit 'd' and then
  204. click the mouse somewhere.  If you are on the ':' line (or '/' or '?'), then
  205. clicking the left or right mouse button will position the cursor on the ':'
  206. line (if 'mouse' contains 'c' or 'a').  In any situation the middle mouse
  207. button may be clicked to paste the current selection.
  208.  
  209.  
  210. 3.2 Visual Selection with Mouse                *gui_mouse_select*
  211.  
  212. The right mouse button may be clicked somewhere to extend the visual
  213. selection to the position pointed to with the mouse.  If already in Visual
  214. mode then the closest end will be extended, otherwise Visual mode is started
  215. and extends from the old cursor position to the new one.
  216.  
  217. Double clicking may be done to make the selection word-wise, triple clicking
  218. makes it line-wise, and quadruple clicking makes it rectangular block-wise.
  219.  
  220. Visual selection, however it is invoked, makes Vim the owner of the
  221. windowing system's primary selection, so that the highlighted text may be
  222. pasted into other windows.  Similarly, selected text from other windows may
  223. be pasted into Vim in Normal mode, Insert mode, or on the ':' line by
  224. clicking the middle mouse button.
  225.  
  226.  
  227. 3.3 Other Text Selection with Mouse        *gui_mouse_xterm_like*
  228.  
  229. When in Command-line mode, at the hit-return prompt or whenever the current
  230. mode is not in the 'mouse' option, a different kind of selection is used.
  231. It is more like what happens in an xterm.  Let's call this xterm-like
  232. selection.  Any text in the Vim window can be selected.  Select the text by
  233. pressing the left mouse button at the start, drag to the end and release.
  234. Right mouse button extends the selection.  Middle mouse button pasts the
  235. text.
  236.  
  237.  
  238. 3.4 Using Mouse on Status Lines                *gui_mouse_status*
  239.  
  240. Clicking the left or right mouse button on the status line below a Vim
  241. window makes that window the current window.  The mouse may then be dragged
  242. up and down to move the status line, thus resizing the windows above and
  243. below it.
  244.  
  245.  
  246. 3.5 Various Mouse Clicks                *gui_mouse_various*
  247.  
  248.     <S-LeftMouse>    Search forward for the word under the mouse click.
  249.     <S-RightMouse>    Search backward for the word under the mouse click.
  250.     <C-LeftMouse>    Jump to the tag name under the mouse click.
  251.     <C-RightMouse>    Jump back to position before the previous tag jump
  252.             (same as "CTRL-T")
  253.  
  254.  
  255. 3.6 Mouse Mappings                    *gui_mouse_mapping*
  256.  
  257. The mouse events, complete with modifiers, may be mapped.  Eg:
  258.     :map <S-LeftMouse>     <RightMouse>
  259.     :map <S-LeftDrag>      <RightDrag>
  260.     :map <S-LeftRelease>   <RightRelease>
  261.     :map <2-S-LeftMouse>   <2-RightMouse>
  262.     :map <2-S-LeftDrag>    <2-RightDrag>
  263.     :map <2-S-LeftRelease> <2-RightRelease>
  264.     :map <3-S-LeftMouse>   <3-RightMouse>
  265.     :map <3-S-LeftDrag>    <3-RightDrag>
  266.     :map <3-S-LeftRelease> <3-RightRelease>
  267.     :map <4-S-LeftMouse>   <4-RightMouse>
  268.     :map <4-S-LeftDrag>    <4-RightDrag>
  269.     :map <4-S-LeftRelease> <4-RightRelease>
  270. These mappings make selection work the way it probably should in a Motif
  271. application, with shift-left mouse allowing for extending the visual area
  272. rather than the right mouse button.
  273.  
  274. Mouse mapping with modifiers does not work for xterm-like selection.
  275.  
  276.  
  277.     4. Making GUI Selections            *gui_selections*
  278.  
  279. You may make selections with the mouse (see |gui_mouse_select|), or by using
  280. Vim's visual mode (see |v|).  If 'a' is present in 'guioptions', then
  281. whenever visual mode is invoked, or when the cursor moves while in visual
  282. mode, Vim becomes the owner of the windowing system's primary selection.
  283. There is a special register for storing this selection, it is the <"*>
  284. register.  Nothing is put in here unless the information about what text is
  285. selected is about to change (eg with a left mouse click somewhere), or when
  286. another application wants to paste the selected text.  Then the text is put
  287. in the <"*> register.  Similarly, when we want to paste a selection from
  288. another application, eg by clicking the middle mouse button, the selection
  289. is put in the <"*> register first, and then 'put' like any other register.
  290.  
  291. Note that when pasting text from one Vim into another separate Vim, the type
  292. of selection (character, line, or block) will also be copied.
  293.  
  294.  
  295.     5. Menus                    *gui_menus*
  296.  
  297. 5.1 Using Menus                        *gui_using_menus*
  298.  
  299. The default menus are quite simple at the moment.  Power Vim users won't use
  300. them much.  But the power is in adding your own menus and menu items.  They
  301. are most useful for things that you can't remember what the key sequence
  302. was.
  303.  
  304. Eventually I would like to expand the set of default menus to use pop up and
  305. other windows for confirmation, file selection etc.  Maybe have a dialogue
  306. box for browsing and choosing buffers, etc.
  307.  
  308. Motif supports Tear-off menus.  These are sort of sticky menus or pop-up
  309. menus that are present all the time.  If the resizing does not work
  310. correctly, this may be caused by using something like "Vim*geometry" in de
  311. defaults.  Use "Vim.geometry" instead.
  312.  
  313. To help you set up your own menus, you can start off with the default set.
  314. See |vim_menu.txt| for a set of menu commands that recreates the default
  315. menus.  You can insert this in your .gvimrc file and change it to your
  316. liking.
  317.  
  318. 5.2 Creating New Menus                    *gui_creating_menus*
  319.  
  320.                     *:me* *:menu* *:noremenu*
  321.                         *:nmenu* *:nnoremenu*
  322.                         *:vmenu* *:vnoremenu*
  323.                         *:imenu* *:inoremenu*
  324.                         *:cmenu* *:cnoremenu*
  325. To create a new menu item, use the ":menu" commands.  They are exactly like
  326. the ":map" set of commands but the first argument is a menu item name, given
  327. as a path of menus and submenus with a '.' between them. eg:
  328.     :menu File.Save  :w^M
  329.     :inoremenu File.Save  ^O:w^M
  330.     :menu Edit.Big\ Changes.Delete\ All\ Spaces  :%s/[ ^I]//g^M
  331.  
  332. This last one will create a new item in the menu bar called "Edit", holding
  333. the mouse button down on this will pop up a menu containing the item
  334. "Big Changes", which is a sub-menu containing the item "Delete All Spaces",
  335. which when selected, performs the operation.
  336.  
  337. Note that the '<' and 'k' flags in 'cpoptions' also apply here (when
  338. included they make the <> form and raw key codes not being recognized).
  339.  
  340.  
  341. 5.3 Showing What Menus Are Mapped To            *gui_showing_menus*
  342.  
  343. To see what an existing menu is mapped to, use just one argument after the
  344. menu commands (just like you would with the ":map" commands).  If the menu
  345. specified is a submenu, then all menus under that hierarchy will be shown.
  346. If no argument is given after :menu at all, then ALL menu items are shown
  347. for the appropriate mode (eg, Command-line mode for :cmenu).
  348.  
  349. Note that hitting <Tab> while entering a menu name after a menu command may
  350. be used to complete the name of the menu item.
  351.  
  352.  
  353. 5.4 Deleting Menus                    *gui_delete_menus*
  354.  
  355.             *:unmenu* *:nunmenu* *:vunmenu* *:iunmenu* *:cunmenu*
  356.             *:unme*   *:nunme*   *:vunme*   *:iunme*   *:cunme*
  357. To delete a menu item or a whole submenu, use the unmenu commands, which are
  358. analogous to the unmap commands.  Eg:
  359.     :unmenu! Edit.Paste
  360.  
  361. This will remove the Paste item from the Edit menu for Insert and
  362. Command-line modes.
  363.  
  364. Note that hitting <Tab> while entering a menu name after an umenu command
  365. may be used to complete the name of the menu item for the appropriate mode.
  366.  
  367. To remove all menus use:
  368.     :unmenu *    " remove all menus in Normal and visual mode
  369.     :unmenu! *    " remove all menus in Insert and Command-line mode
  370.  
  371.  
  372. 5.5 Examples for Menus
  373.  
  374. Here is an example on how to add menu items with menu's!  You can add a menu
  375. item for the keyword under the cursor.  The register "z" is used.
  376.  
  377. :nmenu Words.Add\ Var      wb"zye:menu! Words.<C-R>z <C-R>z<CR>
  378. :nmenu Words.Remove\ Var  wb"zye:unmenu! Words.<C-R>z<CR>
  379. :vmenu Words.Add\ Var      "zy:menu! Words.<C-R>z <C-R>z <CR>
  380. :vmenu Words.Remove\ Var  "zy:unmenu! Words.<C-R>z<CR>
  381. :imenu Words.Add\ Var      <Esc>wb"zye:menu! Words.<C-R>z <C-R>z<CR>a
  382. :imenu Words.Remove\ Var  <Esc>wb"zye:unmenu! Words.<C-R>z<CR>a
  383.  
  384. (the rhs is in <> notation, you can copy/paste this text to try out the
  385. mappings, or put these lines in your gvimrc; "<C-R>" is CTRL-R, "<CR>" is
  386. the <CR> key.  |<>|)
  387.  
  388.  
  389.     6. Extras                    *gui_extras*
  390.  
  391. This section describes other features which are related to the GUI.
  392.  
  393.     - With the GUI, there is no wait for one second after hitting escape,
  394.       because the key codes don't start with <Esc>.
  395.  
  396.     - Typing ^V followed by a special key in the GUI will insert "<Key>",
  397.       since the internal string used is meaningless.
  398.       Modifiers may also be held down to get "<Modifiers-Key>".
  399.  
  400.     - In the GUI, the modifiers SHIFT, CTRL, and ALT (or META) may be used
  401.       within mappings of special keys and mouse events.  eg:
  402.         :map <M-LeftDrag> <LeftDrag>
  403.  
  404.     - In the GUI, several normal keys may have modifiers in mappings etc,
  405.       these are <Space>, <Tab>, <NL>, <CR>, <Esc>.
  406.  
  407.  
  408.     7. Shell Commands                *gui_pty*
  409.  
  410. WARNING: Executing an external command from the GUI will not always work.
  411. "normal" commands like "ls", "grep" and "make" work fine.  Commands that
  412. require an intelligent terminal like "less" and "ispell" won't work.  Some
  413. may even hang and need to be killed from another terminal.  So be careful!
  414.  
  415. There are two ways to do the I/O with a shell command: Pipes and a
  416. pseudo-tty.  The default is to use pipes.  This should work on any Unix
  417. system.  The disadvantage is that some shell commands will notice that a
  418. pipe is being used and behave differently.  The ":sh" command won't show a
  419. prompt, although it will sort of work.  ":!ls" will list the files in one
  420. column.
  421.  
  422. Alternatively a pseudo-tty can be used.  Unfortunately, the implementation of
  423. this is different on every Unix system.  And many systems require root
  424. permission.  Still this might work better than pipes on some systems.  To
  425. see if this works better for you set the 'guipty' option on.  Be prepared to
  426. "kill" the started command or Vim, commands like ":r !cat" may hang!
  427.  
  428.  
  429.     8. Compiling                    *gui_compiling*
  430.  
  431. You need at least Motif version 1.2 and/or X11R5.  Motif 2.0 and X11R6 are
  432. OK.  Motif 1.1 and X11R4 don't work properly (but you might make it work
  433. with a bit of work).
  434.  
  435. By default the Makefile tries to compile Vim with the GUI.  When the Motif
  436. files cannot be found the Athena files will be searched for.  When both of
  437. them cannot be found, the GUI will be disabled.  When you have the Motif or
  438. Athena files in a directory where configure doesn't look, edit the Makefile
  439. to enter the names of the directories.  Search for "GUI_INC_LOC" for an
  440. example to set the Motif directories, "CONF_OPT_X" for Athena.
  441.  
  442. Don't try to mix files from different Motif, Athena and X11 versions.  This
  443. will cause problems.  For example, using header files for X11R5 with a
  444. library for X11R6 probably doesn't work (although the linking won't give an
  445. error message, Vim will crash later).
  446.  
  447. The Athena version uses the Xaw widget set by default.  If you have the 3D
  448. version, you might want to link with Xaw3d instead.  This will make the
  449. menus look a bit better.  Edit the Makefile and look for "XAW_LIB".  The
  450. scrollbars will remain the same, because Vim has its own, which are already
  451. 3D (in fact, they look more like Motif).
  452.  
  453.  
  454.     9. To Do List                    *gui_todo*
  455.  
  456.     - Flashes really badly in certain cases when running remotely from a
  457.       Sun.
  458.  
  459.     - When taking the geometry of the window where gvim was started, check
  460.       that the GUI window will fit on the screen.
  461.  
  462.     - Window should be redrawn when resizing at the hit-return prompt.
  463.  
  464.     - Use different cursor and mouse shapes/colours for different modes.
  465.  
  466.     - Scrollbars with Motif 1.1 are ordered upside down!  Do we care?
  467.  
  468.     - Motif steals <F10> from us, to pop up menus with the keyboard.  How do
  469.       we get it back if we want it?
  470.  
  471.     - Paste in Insert mode should not do autowrap etc.
  472.  
  473.     - Option/resource to use pointer focus from the mouse to select the
  474.       current Vim window.
  475.  
  476.     - Add a new command :highlight for specifying how various things should
  477.       be highlighted, allowing colours to be given.  Currently it's all hard
  478.       coded, the text colour, bg colour etc.
  479.  
  480.     - We need a nice little picture to go on the icon :-)  But how do we do
  481.       that?
  482.  
  483.     - ":menu" should take count for where the menu is inserted (for first
  484.       menu item that doesn't exist yet)
  485.  
  486.     - Would be nice if menu items can be specified for several modes at
  487.       once.
  488.  
  489.     - Make better default menus!
  490.  
  491.     - Add "Buffers" menu, list of (hidden) buffers.
  492.  
  493.     - Add menu item to "Keep Insert mode". More generally: Include a nice
  494.       way to change options.
  495.  
  496.     - When using a pseudo-tty Vim should behave like some terminal. Terminal
  497.       codes to/from shell should be translated.
  498.  
  499.     - Make it easy to specify a shorcut (key) for a menu item.
  500.  
  501.     - :mkgvimrc command, that includes menus.
  502.  
  503.     - Would it be useful to be able to quit the GUI and go back to the
  504.       terminal where it was started from?
  505.  
  506.     - Finish off the todo list!
  507.  
  508.  
  509.  vim:tw=76:ts=8:sw=4
  510.